home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Hardware / BlizKick / Modules / NoClick.ASM < prev    next >
Encoding:
Assembly Source File  |  2002-03-13  |  4.0 KB  |  167 lines

  1. ; FILE: Source:modules/NoClick.ASM          REV: 6 --- NoClick patch
  2.  
  3. ;
  4. ; Drive NoClick -Module
  5. ; ~~~~~~~~~~~~~~~~~~~~~
  6. ; This patch module will turn off drive clicking at very early time...
  7. ; Actually my floppy drive manages to click only once upon reset... :)
  8. ;
  9. ; 1.0: Initial release
  10. ; 1.1: Added support for hackdisk.device. You must specify NoClick
  11. ;      module *AFTER* hackdisk module if you want it function!
  12. ; 1.2: Made it possible to patch trackdisk.device that is fully or
  13. ;      partially inside extresbuf. Changed the way the patch is
  14. ;      applied to avoid problems with specific ROM version (40.70
  15. ;      A3000 and A4000 had problems, however 40.70 A4000T worked).
  16. ;
  17. ; Written by Harry Sintonen.
  18. ; This source code is Public Domain.
  19. ;
  20.  
  21.     incdir    "include:"
  22.     include    "blizkickmodule.i"    ; Some required...
  23.  
  24.  
  25.     SECTION    PATCH,CODE
  26. _DUMMY_LABEL
  27.     BK_PTC
  28.  
  29. ; Code is run with following incoming parameters:
  30. ;
  31. ; a0=ptr to ROM start (buffer)    eg. $1DE087B8
  32. ; a1=ptr to ROM start (ROM)    eg. $00F80000 (do *not* access!)
  33. ; d0=ROM lenght in bytes    eg. $00080000
  34. ; a2=ptr to _FindResident routine (will search ROM buffer for resident tag):
  35. ;    CALL: jsr (a2)
  36. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to resident name
  37. ;     OUT: d0=ptr to resident (buf) or NULL
  38. ; a3=ptr to _InstallModule routine (can be used to plant a "module"):
  39. ;    CALL: jsr (a3)
  40. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to module, d6=dosbase
  41. ;     OUT: d0=success
  42. ; a4=ptr to _Printf routine (will dump some silly things (errormsg?) to stdout ;-)
  43. ;    CALL: jsr (a4)
  44. ;      IN: a0=FmtString, a1=Array (may be 0), d6=dosbase
  45. ;     OUT: -
  46. ; d6=dosbase, a6=execbase
  47. ;
  48. ; Code should return:
  49. ;
  50. ; d0=true if succeeded, false if failed.
  51. ; d1-d7/a0-a6 can be trashed. a7 *must* be preserved! ;-)
  52.  
  53.     moveq    #0,d7
  54.  
  55.     cmp.w    #37,($C,a0)        ; Requires KS V37+
  56.     blo    .exit
  57.  
  58.     lea    (regs,pc),a5
  59.     movem.l    d0/a0-a1,(a5)
  60.  
  61.     lea    (_tdname,pc),a1        ; _FindResident
  62.     jsr    (a2)
  63.     tst.l    d0
  64.     beq.b    .exit
  65.     move.l    d0,a2            ; a2=trackdisk resident
  66.  
  67.     cmp.b    #37,(RT_VERSION,a2)    ; V37+
  68.     blo.b    .exit
  69.     btst    #RTB_COLDSTART,(RT_FLAGS,a2) ; Coldstart
  70.     beq.b    .exit
  71.     move.l    (RT_IDSTRING,a2),d0
  72.     beq.b    .exit
  73.     bsr    buffer
  74.     move.l    d0,a5            ; a5=RT_IDSTRING in buffer
  75.  
  76.     cmp.b    #'H',(a5)+        ; Hackdisk.device?
  77.     bne.b    .nhackd
  78.     cmp.b    #'a',(a5)
  79.     beq.b    .ishackd
  80. .nhackd
  81.     move.l    a2,a5            ; a5=ptr in buffer
  82.     move.l    (RT_ENDSKIP,a2),d0
  83.     bsr    buffer
  84.     sub.l    a2,d0
  85.     lsr.l    #1,d0
  86.     subq.l    #8,d0            ; max num of words to search
  87.     ble.b    .perr
  88.  
  89. .find    addq.l    #2,a5            ; Magic Begins Here:
  90.     subq.l    #1,d0
  91.     beq.b    .exit
  92.     cmp.l    #$FFFFFFFF,(a5)        ; tdu_Comp10Track = -1, tdu_Comp11Track = -1
  93.     bne.b    .find
  94.     tst.w    (4,a5)            ; (tdu_tdu_StepDelay & 0xffff0000) == 0
  95.     bne.b    .find
  96.     cmp.l    #15000,(8,a5)        ; tdu_SettleDelay = 15000
  97.     bne.b    .find
  98.     cmp.l    #(10<<24)|(0<<16)|$ffff,(12,a5)    ;tdu_RetryCnt = 10, tdu_PubFlags = 0, tdu_CurrTrk = -1
  99.     bne.b    .find
  100.     or.b    #1,(12+1,a5)        ; tdu_PubFlags = TDPF_NOCLICK
  101.     moveq    #1,d7
  102.     bra.b    .find
  103.  
  104. .exit    move.l    d7,d0            ; Valid counter?
  105.     bne.b    .xit
  106.     lea    (_error1,pc),a0        ; a0=fmt
  107.     pea    (_tdname,pc)
  108.     move.l    sp,a1            ; a1=array
  109.     jsr    (a4)            ; Call _Printf
  110.     addq.l    #4,sp
  111. .fail    moveq    #0,d0            ; Return fail
  112. .xit    rts
  113.  
  114. .perr    lea    (_error2,pc),a0
  115.     jsr    (a4)            ; Call _Printf
  116.     bra.b    .fail    
  117.  
  118.  
  119.     ; Handle hackdisk.device
  120. .ishackd
  121.     bclr    #0,d0            ; Align word
  122.     move.l    d0,a5            ; a5=ptr in buffer
  123.  
  124.     move.l    #8192/2,d0        ; Max Num of words to seach
  125. .hfind    addq.l    #2,a5            ; MoreMagic Begins Here:
  126.     subq.l    #1,d0
  127.     beq.b    .perr
  128.     cmp.l    #$08EC0001,(a5)
  129.     bne.b    .hfind
  130.     cmp.w    #53,(4,a5)        ; TDU_PUBFLAGS
  131.     bne.b    .hfind
  132.  
  133.     move.l    #$197C0003,(a5)        ; Change!
  134.     moveq    #1,d7
  135.     bra.b    .exit
  136.  
  137.  
  138.  
  139. buffer    ;test if inside rom bounds?
  140.     move.l    (rom_log,pc),d1
  141.     cmp.l    d1,d0
  142.     blo.b    .nofix
  143.     add.l    (rom_size,pc),d1
  144.     cmp.l    d1,d0
  145.     bhs.b    .nofix
  146.     ; inside rom, so generate ram buffer address
  147.     sub.l    (rom_log,pc),d0        -$f80000
  148.     add.l    (rom_phys,pc),d0    +buffer
  149. .nofix    rts
  150.  
  151.  
  152.  
  153. _tdname    dc.b    'trackdisk.device',0
  154.  
  155. _error1    dc.b    'NoClick: This patch requires %s V37+!',10,0
  156. _error2    dc.b    'NoClick: Couldn''t patch!',10,0
  157.  
  158.     CNOP    0,2
  159. regs
  160. rom_size    ds.l    1
  161. rom_phys    ds.l    1
  162. rom_log    ds.l    1
  163.  
  164.     SECTION    VERSION,DATA
  165.  
  166.     dc.b    '$VER: NoClick_PATCH 1.2 (13.12.00)',0
  167.